<?php
/**
 * @package Autogenerator for Joomla!
 * @version 3.0.0
 * @author Truong Cong Duc <truongcongduc4@gmail.com>
 * @link autogenerator.blogspot.com
 * @copyright (c) 2013, Truong Cong Duc
 * @license GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

class AutogeneratorViewImport extends JViewLegacy {

    protected $form;
    protected $item;
    protected $state;
    protected $oApplication;

    public function __construct($aConfig = array()) {
        parent::__construct($aConfig);

        $this->oApplication = JFactory::getApplication();
    }

    public function display($tpl = null) {
        $iComponentId = $this->oApplication->input->getInt('iComponentId');

        if ($iComponentId == 0) {
            $sMessage = JText::_('COM_AUTOGENERATOR_IMPORT_ERROR_MESSAGE_COMPONENT_NOT_VALID');

            $this->oApplication->redirect('index.php?option=com_autogenerator&view=components', $sMessage, 'error');
        }

        $this->form = $this->get('Form');
        $this->item = $this->get('Item');
        $this->state = $this->get('State');

        $this->aSelectedTables = $this->get('SelectedTables');
        
        $this->addToolbar();

        parent::display($tpl);
    }

    protected function addToolbar() {
        $this->oApplication->input->set('hidemainmenu', true);

        JToolbarHelper::title(JText::_('COM_AUTOGENERATOR_IMPORT_DETAILS'), 'article.png');

        JToolbarHelper::apply('import.apply');
        JToolbarHelper::save('import.save');
        JToolbarHelper::cancel('import.cancel');
    }

}
